package com.jxwifi.cloud.quickcleanserver.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import static com.alibaba.sdk.android.ams.common.global.AmsGlobalHolder.getPackageName;

/**
 * 
 */
public class ToBaidu implements INavigation {

	protected String mShopName;

	public ToBaidu(String shopName) {
		super();
		this.mShopName = shopName;
	}

	public void startAutonavi(final Context context, String lng, String lat) {

		double pi = 3.1415926535897932384626;
		double x = Double.parseDouble(lng), y = Double.parseDouble(lat);
		double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
		double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
		double bd_lon = z * Math.cos(theta) + 0.0065;
		double bd_lat = z * Math.sin(theta) + 0.006;


		Intent intent = new Intent();
		intent.setData(Uri.parse("baidumap://map/direction?destination=latlng:"
				+ bd_lat + ","
				+ bd_lon + "|name:" + mShopName + // 终点
				"&mode=driving" + // 导航路线方式
				"&src=" + getPackageName()));
		context.startActivity(intent); // 启动调用

	}

}
